#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
char s[1100];
char aim[1100];
int main()
{
	int n;
	cin>>n;
	cin>>s>>aim;
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		int a = s[i]-'0';
		int b = aim[i]-'0';
	    if(a>=b) ans += min((a-b),(10-a)+b);
		else ans += min((b-a),a+(10-b));
	}
	cout<<ans<<endl;
} 
